package com.css.apps.base.post.model;

import java.io.Serializable;

import com.css.apps.base.role.model.SRole;
import com.css.apps.base.user.model.SUser;
import com.css.core.model.IPost;
import com.css.db.query.JoinList;
import com.css.db.query.QueryCache;
import com.css.util.Json.Unjson;

@SuppressWarnings("serial")
public class SPost implements IPost, Serializable {

	private String uuid;
	private String name;
	private String remark;
	private String groupFlag;
	private Integer orderNum;

	private transient JoinList postUserList = null;
	private transient JoinList postRoleList = null;

	public String getUuid() {
		return this.uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getPostId() {
		return this.uuid;
	}

	public String getPostName() {
		return this.name;
	}

	@Unjson
	public JoinList getPostUserList() {
		if (postUserList == null) {
			QueryCache qc = new QueryCache(
					"select a.userId from SUserPost a,SUser b where a.userId=b.uuid and  a.postId = :postId and b.delFlag='2' and b.openFlag != '2'")
					.setParameter("postId", uuid);
			postUserList = new JoinList(SUser.class, qc);
		}
		return postUserList;
	}

	@Unjson
	public JoinList getPostRoleList() {
		if (postRoleList == null) {
			QueryCache qc = new QueryCache("select r.roleId from SPostRole r where r.postId = :postId ")
					.setParameter("postId", uuid);
			postRoleList = new JoinList(SRole.class, qc);
		}
		return postRoleList;
	}

	public String getGroupFlag() {
		return groupFlag;
	}

	public void setGroupFlag(String groupFlag) {
		this.groupFlag = groupFlag;
	}

	public Integer getOrderNum() {
		return orderNum;
	}

	public void setOrderNum(Integer orderNum) {
		this.orderNum = orderNum;
	}

}